let mongoose = require('./db')
let Schema = mongoose.Schema

// 策略表
let strategySchema = Schema({
    name: String,
    scheme:Number,
    createTime: {
        type: Date,
        default: Date.now
    },
    updateTime: {
        type: Date,
        default: Date.now
    }
},{
    versionKey: false,
    timestamps: { createdAt: 'createTime', updatedAt: 'updateTime' }
})

// 设备类型表
let equipmentTypeSchema = Schema({
    name: String,
    coding:String,
    line:Number,
    number:Number,
    capacity:Number,
    imgs:String
})

// 设备表
let equipmentSchema = Schema({
    state:String,
    typeid:{
        type:mongoose.Types.ObjectId,
        ref:'equipmentType'
    },
    ptid:{
        type:mongoose.Types.ObjectId,
        ref:'point'
    },
    strategyid:String,
    createTime: {
        type: Date,
        default: Date.now
    },
    updateTime: {
        type: Date,
        default: Date.now
    }
},{
    versionKey: false,
    timestamps: { createdAt: 'createTime', updatedAt: 'updateTime' }
})

let strategyModel = mongoose.model('strategy', strategySchema)
let equipmentTypeyModel = mongoose.model('equipmentType', equipmentTypeSchema)
let equipmentModel = mongoose.model('equipment', equipmentSchema)

module.exports = {
    strategyModel,
    equipmentTypeyModel,
    equipmentModel,
}
